home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Alert;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.List;
- import javax.microedition.lcdui.TextBox;
- import javax.microedition.midlet.MIDlet;
- import javax.microedition.rms.RecordStore;
-
- public class MiniPad extends MIDlet implements CommandListener {
- // $FF: renamed from: rs javax.microedition.rms.RecordStore
- private RecordStore field_0 = null;
- static int MAX_TEXT = 2000;
- static byte[] bDummy = new byte[]{0, 0};
- static String header = "MiniPad by RizaPN";
- private Command cmExit = new Command("Exit", 7, 4);
- private Command cmSaveE = new Command("Save&Exit", 1, 0);
- private Command cmLine = new Command("Insert NewLine", 1, 1);
- private Command cmSaveC = new Command("Save&Continue", 1, 3);
- private Command cmDelete = new Command("Delete Entry", 1, 5);
- private Command cmDisc = new Command("Discard", 1, 7);
- private Command cmOK = new Command("OK", 7, 6);
- private Command cmCancel = new Command("Cancel", 7, 7);
- private Display display;
- private List list00;
- private Alert alert;
- private TextBox text1;
- private TextBox fname;
- private byte nStatus;
- private byte sStatus;
-
- public MiniPad() {
- this.list00 = new List(header, 3);
- this.alert = new Alert(header);
- this.text1 = new TextBox(header, "", MAX_TEXT, 0);
- this.fname = new TextBox("Entry Title", "", 32, 0);
- this.nStatus = 0;
- this.sStatus = 0;
- this.display = Display.getDisplay(this);
- }
-
- public void initlist00() {
- int var1 = this.list00.size();
-
- while(var1 > 0) {
- --var1;
- this.list00.delete(var1);
- }
-
- this.list00.append("<New Entry>", (Image)null);
-
- try {
- String[] var2 = RecordStore.listRecordStores();
-
- for(int var5 = 0; var5 < var2.length; ++var5) {
- this.list00.append(var2[var5], (Image)null);
- }
- } catch (Exception var4) {
- }
-
- }
-
- protected void startApp() {
- this.initlist00();
- this.display.setCurrent(this.list00);
- this.list00.addCommand(this.cmExit);
- this.list00.setCommandListener(this);
- this.text1.addCommand(this.cmSaveE);
- this.text1.addCommand(this.cmSaveC);
- this.text1.addCommand(this.cmDisc);
- this.text1.addCommand(this.cmDelete);
- this.text1.addCommand(this.cmLine);
- this.fname.addCommand(this.cmOK);
- this.fname.addCommand(this.cmCancel);
- }
-
- public void commandAction(Command var1, Displayable var2) {
- byte var3 = 9;
- if (var1 == this.cmExit) {
- this.destroyApp(false);
- } else if (var1 != this.cmOK && var1 != this.cmCancel && var1 != this.cmDisc) {
- if (var1 != this.cmSaveE && var1 != this.cmSaveC) {
- if (var1 == this.cmDelete) {
- String var12 = this.fname.getString();
-
- try {
- RecordStore.deleteRecordStore(var12);
- } catch (Exception var9) {
- }
-
- this.commandAction(this.cmDisc, (Displayable)null);
- } else if (var1 == this.cmLine) {
- this.text1.insert("\n", this.text1.getCaretPosition());
- } else {
- int var15 = this.list00.getSelectedIndex();
- String var13 = this.list00.getString(var15);
- this.fname.setString("");
- this.text1.setString("");
-
- try {
- this.field_0 = RecordStore.openRecordStore(var13, false);
- this.fname.setString(var13);
- var13 = new String(this.field_0.getRecord(1));
- this.text1.setString(var13);
- } catch (Exception var8) {
- }
-
- try {
- this.field_0.closeRecordStore();
- } catch (Exception var7) {
- }
-
- this.display.setCurrent(this.text1);
- this.text1.setCommandListener(this);
- this.sStatus = 0;
- }
- } else {
- if (var1 == this.cmSaveC) {
- this.nStatus = var3;
- }
-
- this.display.setCurrent(this.fname);
- this.fname.setCommandListener(this);
- }
- } else {
- if (var1 == this.cmOK) {
- try {
- String var4 = this.fname.getString();
- if (var4.charAt(0) == '<') {
- return;
- }
-
- this.field_0 = RecordStore.openRecordStore(var4, true);
- if (this.field_0.getNumRecords() == 0) {
- this.field_0.addRecord(bDummy, 0, 2);
- }
-
- byte[] var5 = this.text1.getString().getBytes();
- this.field_0.setRecord(1, var5, 0, var5.length);
- this.sStatus = 1;
- } catch (Exception var11) {
- }
-
- try {
- this.field_0.closeRecordStore();
- } catch (Exception var10) {
- }
- }
-
- if (this.nStatus != var3 && var1 != this.cmCancel) {
- this.initlist00();
- this.display.setCurrent(this.list00);
- this.list00.setCommandListener(this);
- } else {
- this.display.setCurrent(this.text1);
- this.text1.setCommandListener(this);
- }
-
- this.nStatus = 0;
- }
-
- }
-
- protected void pauseApp() {
- }
-
- protected void destroyApp(boolean var1) {
- ((MIDlet)this).notifyDestroyed();
- }
- }
-